package com.common.retrofit.method;

import com.common.Entity.WechatLoginEntity;
import com.common.cons.Constans;
import com.common.retrofit.base.BaseMethods;
import com.common.retrofit.service.DuoBaoService;
import com.common.utils.SortUtils;

import rx.Observable;
import rx.Subscriber;

public class WechatLoginMethods extends BaseMethods {

    private static WechatLoginMethods m_ins = null;

    public static WechatLoginMethods getInstance() {
        if (m_ins == null) {
            synchronized (WechatLoginMethods.class) {
                if (m_ins == null) {
                    m_ins = new WechatLoginMethods();
                }
            }
        }
        return m_ins;
    }

    @Override
    protected String getHttpUrl() {
        return "api/User/";
    }

    private DuoBaoService initService() {
        return getRetrofit().create(DuoBaoService.class);
    }


    public void     quickLogin      (Subscriber<WechatLoginEntity> subscriber,
                      String weixin_token ,
                      String jpushid ,String weixin_name

    ) {
        String time  = System.currentTimeMillis()+"" ;
        Observable observable = initService().quickLogin(time,
                SortUtils.getMyHash("weixin_token"+weixin_token,"jpushid"+jpushid ,"time"+time,"weixin_name"+weixin_name), Constans.ANDROID_APP_ID,"3",
               weixin_token,jpushid ,weixin_name
        );
        toSubscribe(observable, subscriber);
    }
}
